home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8508.arc / XMTBL.C < prev   
Text File  |  1986-09-14  |  1KB  |  71 lines

  1. /* xmtbl.c - transmit chars test - Blaise version */
  2. #include "stdio.h"
  3. #include "asynch_1.h"
  4.  
  5. #define CARD  2
  6.  
  7. char combuf[1150] ;
  8. int nerr = 0 ;
  9. FILE *fopen() ;
  10.  
  11. main(argc,argv)
  12.  int argc ;
  13.  char *argv[] ;
  14.  {
  15.     int c , err , n , t , speed ;
  16.     char b ;
  17.     unsigned status ;
  18.     FILE *in ;
  19.  
  20.     if( argc < 3 )
  21.       { printf(" no file name on command line \n");
  22.         exit(5) ;
  23.       }
  24.  
  25.  
  26.     in = fopen(argv[1],"rb");
  27.     if( in == NULL )
  28.       { printf(" can't open input file \n") ;
  29.         exit(10) ;
  30.       }
  31.     sscanf(argv[2],"%d",&speed) ;
  32.     init_a1(COM2,speed,2,0,2,&status,&status) ;
  33.     err = open_a1(COM2,1000,100,0,0,combuf) ;    /* set up for RS-232 use */
  34.  
  35.     send_chr('S') ;
  36.     n = 0 ;
  37.     eltime() ;            /* start timing */
  38.     while( (c = fgetc(in) ) != EOF )
  39.       { send_chr(c) ; }
  40.     send_chr('Q') ;
  41.     t = eltime() ;        /* stop timing */
  42.     printf(" %d Ticks  %8.2f Secs \n",t,( (float) t)/18.2) ;
  43.  
  44.     fclose(in) ;
  45.     wait_a1(100) ;
  46.     close_a1(COM2) ;
  47.  }
  48.  
  49.  
  50. int rcv_chr()            /* wait for and get next char */
  51.  {
  52.     int c , err , n ;
  53.     char b ;
  54.     unsigned status ;
  55.  
  56.     while( (err=rdch_a1(COM2,&b,&n,&status)) != 0)
  57.       { ; }
  58.     return( (int) b ) ;
  59.  }
  60.  
  61.  
  62.  
  63. int send_chr(c)            /* wait and xmt next char */
  64.  int c ;
  65.  {
  66.  
  67.     while( wrtch_a1(COM2,c)  != 0 )
  68.       { ; }
  69.  }
  70.  
  71.